<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets">

<h:body>
	<ui:composition template="/pages/templates/master.xhtml">
			<ui:define name="tituloPagina">
            Cadastro de Usuários
        	</ui:define>
	
	<ui:define name="conteudo">
	<h:form id="form" prependId="true" acceptcharset="ISO-8859-1">
 				<p:growl id="messages" autoUpdate="true"/>

		<p:panel menuTitle="Usuário" header="Usuário" id="cadastro">

			<h:inputHidden id="teste" value="#{administradorBean.administrador.id}" /><br />
			
	  			<h:outputLabel value="Matricula*:" /><br />
				<p:inputText value="#{administradorBean.administrador.funcionario.matricula}"
					id="matricula"
					required="true" 
					style="color: black;" 
					requiredMessage="Matrícula Obrigatória" /><br />

				<h:outputLabel value="Email*:" /><br />
				<p:inputText value="#{administradorBean.administrador.email}" 
						required="true" 
						style="color: black;" 
						requiredMessage="Email é obrigatório" /><br />

				<h:outputLabel value="Senha*:" /><br />
	          	<p:inputText id="senha" 
		          	label="Senha" 
		          	value="#{administradorBean.administrador.senha}" 
		          	required="true" 
		          	requiredMessage="Senha é Obrigatório" 
		          	style="color: black;" />
				
				<br />
			
			<br />

			<p:separator />

			<p:commandButton value="Salvar" 
								action="#{administradorBean.salvar}"
								update="form,:consulta" />
								
		</p:panel>

		<br />
	</h:form>


	<h:form id="consulta">

		<p:dataTable id="dataTable" var="var"
			value="#{administradorBean.listaAdministrador}" paginator="true" rows="1"
			rendered="#{not empty administradorBean.listaAdministrador}"
			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			rowsPerPageTemplate="1,5,10">

			<p:column>
				<f:facet name="header">
					<h:outputText value="Matrícula" />
				</f:facet>
				<h:outputText value="#{var.funcionario.matricula}" editable="true" />

			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="Login" />
				</f:facet>
				<h:outputText value="#{var.email}" />
			</p:column>

			<!-- 	<p:column>
				<f:facet name="header">
					<h:outputText value="Perfil" />
				</f:facet>
				<h:outputText value="#{var.perfil}" />
			</p:column> -->

			<p:column>
				<p:commandLink value="Excluir" update=":form,:consulta"
					title="Excluir" action="#{administradorBean.excluir}">
					<f:setPropertyActionListener value="#{var}"
						target="#{administradorBean.administrador}" />
				</p:commandLink>
			</p:column>

			<p:column>
				<p:commandLink value="Editar" update=":form,:consulta"
					action="#{usuarioBean.editAction(var)}">
					<f:setPropertyActionListener value="#{var}"
						target="#{administradorBean.administrador}" />
				</p:commandLink>
			</p:column>

			<p:column>
				<p:commandLink value="Relatório"
					action="#{administradorBean.editAction(var)}" />
			</p:column>

		</p:dataTable>

		<!--  	<p:commandButton value="Voltar" action="pagInicial"></p:commandButton> -->


	</h:form>
	</ui:define>
	</ui:composition>
</h:body>
</html>